﻿/*
 * Toast8
 * All rights reserved
 * Copyright (C) 2014 Peter Nylander
 */

using Hardcodet.Wpf.TaskbarNotification;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Toast8
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private TaskbarIcon notifyIcon;
        public static Toast8ViewModel ViewModel;

        protected async override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            
            notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");

            // Create view model and initialize
            ViewModel = new Toast8ViewModel();
            await ViewModel.Initialize();

            notifyIcon.DataContext = ViewModel;

            // Start timer but only if Spotify is started
            ViewModel.Start();
        }

        protected override void OnExit(ExitEventArgs e)
        {
            notifyIcon.Dispose(); //the icon would clean up automatically, but this is cleaner
            base.OnExit(e);
        }
    }
}
